<?php

$currCat = get_the_category();
$current = $currCat[0]->name;
$post_title = get_the_title();


//staff variables
$staff_id = get_cat_ID( 'Staff' );
$staff_link = get_category_link( $staff_id );
if ( stristr( $post_title, 'staff' ) ) {
	wp_redirect( $staff_link ); exit;
}

if ($current == 'People') {
	if ( get( 'general_detail_if_staff' ) == 'Yes' ) {
		$name_slug = $post->post_name;
		$staff_redirect_link = add_query_arg( 'staff-member', $name_slug, $staff_link );
		wp_redirect( $staff_redirect_link ); exit;
	}
}


if ( $current == 'Individual Projects' ) {
	$faux_cat_post_id = get( 'details_project_category' );
    $faux_cat_link = get_permalink( $faux_cat_post_id );
	$individual_project = $post->post_name;
    $faux_post_link = add_query_arg( 'project', $individual_project, $faux_cat_link );
	wp_redirect( $faux_post_link ); exit;
}

if ( isset( $_GET['project'] ) ) {
	 include 'single-projects.php';
}

else
$project_cat_query = new WP_Query( array ( 'category_name' => 'Projects', 'posts_per_page' => -1 ) );
while( $project_cat_query->have_posts() ) : $project_cat_query->the_post();
	$projects_cats[] = get_the_title();
endwhile;
wp_reset_postdata();

if ( in_array( $post_title, $projects_cats ) ) {
    include 'custom-projects-archive.php';
}

elseif( in_array( $post_title, array( 'Coordinating Committee', 'Teaching Faculty' ) ) ) {
    include 'single-cert-people.php';
}

elseif ($current == 'Publications') {
	include 'single-publications.php';
}

elseif ($current == 'Classes') {
// Custom Template for Single Posts in Category 'Classes'
	include 'single-classes.php';
}

elseif ($current == 'Finding Guides') {
// Custom Template for Single Posts in Category 'Collection Highlights'
	include 'single-finding-guides.php';
}

elseif ($current == 'Collection Highlights') {
// Custom Template for Single Posts in Category 'Collection Highlights'
	include 'single-collection-highlights.php';
}

elseif ($current == 'Staff') {
// Custom Template for Single Posts in Category 'Staff'
	include 'single-staff.php';
}

elseif ($post_title == 'Members') {
// Custom Template for Single Posts in Category 'Staff'
	include 'single-advisory-members.php';
}

elseif ( $post_title =='Certificate Classes') {
// Custom Template for Single Posts in Category 531
	include 'single-cert-classes.php';
}

else {

?>
<?php
global $options;
foreach ($options as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
$dateformat = get_option('date_format');
$timeformat = get_option('time_format');
$layout = get_post_meta($post->ID, 'template', true);
get_header(); ?>


  <div id="content">
    <div class="wrap">

      <?php wp_reset_query();
      if (have_posts()) : while (have_posts()) : the_post(); ?>

      <?php if ($layout != 'full') { ?>
      <div class="column column-narrow">

      	<?php
      	$currCat = get_the_category();
      	$current = $currCat[0]->name;
      	$parent = get_cat_name($currCat[0]->category_parent);

    	echo "<p class='heading'>".$parent."</p>";

		list_cat_posts_all();

		?>

        <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar: Posts (Left)') ) : ?>&nbsp;<?php endif; ?>

      </div><!-- end .column-narrow -->
      <?php } ?>

      <div class="column <?php if ($layout == 'double') {echo"column-double column-last ";} if ($layout == 'full') {echo"column-full column-last ";} ?>column-content column-double">
	  	<div id="crumbs">
			<!--?php the_breadcrumb(); ?-->
			<?php
				$args = array(
					'prefix' => '<p>',
					'suffix' => '</p>',
					'title' => __( '', 'breadcrumbs-plus' ),
					'home' => __( 'Home', 'breadcrumbs-plus' ),
					'sep' => '»',
					'front_page' => false,
					'bold' => true,
					'show_blog' => false,
					'echo' => true,
					'singular_post_taxonomy' => 'category',
				);
				breadcrumbs_plus( $args );
			?>
		</div>
	  	<h1><?php the_title(); ?></h1>

        <?php the_content(''); ?>

        <?php
			if ( is_single( 'hours' ) ) {
				if( function_exists( 'class_calendar' ) ) {
					class_calendar();
				}
			}
		?>

        <?php wp_link_pages(array('before' => '<p class="pages"><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
        <?php the_tags( '<p class="tags"><strong>Tags:</strong> ', ', ', '</p>'); ?>
        <p class="postmetadata"> Updated <span class="datetime"><?php the_time("$dateformat"); ?></span> <?php if ( $currCat[0]->category_count > '1' ) { ?>&nbsp;&nbsp; Go back to <span class="category"><?php the_category(', '); ?></span><?php } ?></p>
        <?php comments_template(); ?>

      </div><!-- end .column-content -->

      <?php if ($layout != 'double' && $layout != 'full') { ?><div class="column column-narrow column-last">

        <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar: Posts (Right)') ) : ?>&nbsp;<?php endif; ?>

      </div><!-- end .column-narrow -->
      <?php } ?>

<?php endwhile; endif; ?>

      <div class="clear">&nbsp;</div>

    </div><!-- end .wrap -->
  </div><!-- end #content -->

<?php get_footer(); ?>
<?php } ?>